#ifndef SimpleLocationService_H
#define SimpleLocationService_H

#include "ns3/node.h"
#include "ns3/node-list.h"
#include "ns3/ipv4-routing-protocol.h"
#include "ns3/ipv4-interface.h"
#include "ns3/ipv4-l3-protocol.h"
#include "sls.h"
#include "ns3/location-service.h"
#include "ns3/vector.h"
#include <map>
#include "sls-table.h"

namespace ns3
{

class SimpleLocationService : public LocationService
{
public:

  SimpleLocationService (Time tableLifeTime);
  SimpleLocationService ();
  virtual ~SimpleLocationService();
  virtual void DoDispose ();
  Vector GetPosition (Ipv4Address adr);
  bool HasPosition (Ipv4Address adr);
  bool IsInSearch (Ipv4Address adr);

  void SetIpv4 (Ptr<Ipv4> ipv4);
  Vector GetInvalidPosition ();
  //Time GetEntryUpdateTime (Ipv4Address id);
  //void AddEntry (Ipv4Address id, Vector position, Time time, bool researchFlag , uint8_t numSeq);
  //void DeleteEntry (Ipv4Address id);
  void Purge ();
  virtual void Clear ();

  /* Funções que permitem aceder à tabela directamente */
  Time GetEntryUpdateTime(Ipv4Address id){ return m_table.GetEntryUpdateTime(id); }
  void AddEntry(Ipv4Address id, Vector position) {m_table.AddEntry(id, position, Time(0),false, 0); }
  void DeleteEntry(Ipv4Address id) {m_table.DeleteEntry(id); }
  MapEntry GetEntry(Ipv4Address id) {return m_table.GetEntry(id);}

  /* Permite sacar uma posiçao de um id da tabela.
   * FIXME: invVec no argumento não seria necessário caso eu conseguisse invocar a
   * função GetInvalidVector */
  //Vector GetPosition(Ipv4Address id, Vector invVec) {return m_table.GetPosition(id, invVec); }
  //bool IsInSearch(Ipv4Address id) { return m_table.GetResearchFlag(id); }

private:
 /// start protocol operation
 void Start ();
 Time m_entryLifeTime;
 PositionTable m_table;

};
}
#endif /* SimpleLocationService_H */

